home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Yerk 3.64 / Supplement / Unsupported / Utilities / sortFile < prev    next >
Text File  |  1986-10-19  |  755b  |  35 lines

  1. \ sort an ascii file
  2. \ 10/19/86  cdn Version 1.0
  3.  
  4. 500 Ordered-Col lines
  5.  
  6. \ ( addr1 addr2 -- result )
  7. : compStr
  8.     swap count rot count $=
  9. ;
  10.  
  11. : sortFile
  12.     new: loadFile
  13.     txType 1 stdget: topFile 0= IF exit THEN
  14.     open: topFile abort" Can't open file"
  15.     CR ." Reading file…"
  16.     BEGIN
  17.         buf255 255 readLine: topFile 0=
  18.     WHILE
  19.         bytesRead: topFile 1+ newPtr -dup 0= abort" Ran out of memory!"
  20.         dup add: lines
  21.         buf255 bytesRead: topFile rot >str255 drop
  22.     REPEAT
  23.     close: topFile drop
  24.     CR ." Sorting" size: lines . ." lines…"
  25.     ixAddr: lines size: lines 'c compStr sort
  26.     CR ." Writing file…"
  27.     open: topFile abort" Can't reopen file"
  28.     size: lines 0
  29.     DO    i at: lines dup count write: topFile abort" Write failed!"
  30.         killPtr
  31.     LOOP
  32.     close: topFile drop
  33.     remove: loadFile
  34. ;
  35.